package work.model.com.mymvvm;

import android.content.Intent;
import android.databinding.DataBindingUtil;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.view.View;

import java.util.ArrayList;
import java.util.List;

import work.model.com.mymvvm.databinding.MainBinding;

public class MainActivity extends AppCompatActivity {
    private MainBinding mainBinding;
    private List<UserBean> mUserBeanList =new ArrayList<>();
    private MainAdapter mainAdapter;
    private UserBean1 userBean1;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        mUserBeanList.add(new UserBean("xiaoming","111"));
        mUserBeanList.add(new UserBean("xiaosing","116"));
        mUserBeanList.add(new UserBean("xiaoding","151"));
        mUserBeanList.add(new UserBean("xiaohing","141"));
        mUserBeanList.add(new UserBean("xiaoeing","113"));
        mUserBeanList.add(new UserBean("xiaoqing","121"));

        userBean1= new UserBean1();
        userBean1.age.set("kkk");
        mainBinding = DataBindingUtil.setContentView(this,R.layout.main);
        mainAdapter=new MainAdapter(mUserBeanList);
        mainBinding.recyclerView.setLayoutManager(new LinearLayoutManager(this));
        mainBinding.recyclerView.setAdapter( mainAdapter);
        mainBinding.btnRefresh.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                startActivity(new Intent( MainActivity.this,TextActivity.class));
              /*  mUserBeanList.clear();
                mUserBeanList.add(new UserBean("xiaohing","141"));
                mUserBeanList.add(new UserBean("xiaoeing","113"));
                mUserBeanList.add(new UserBean("xiaoqing","121"));*/

            }
        });

    }
}
